package com.caption.design.adapter;

/**
 * 采用对象适配的模式
 */
public class VoltageAdapter implements VoltageTarget {

    private VoltageSource voltageSource;

    public VoltageAdapter(VoltageSource voltageSource) {
        this.voltageSource = voltageSource;
    }

    @Override
    public Integer output5V() {
        Integer source = voltageSource.output220V();
        Integer target = cover(source);
        return target;
    }

    private Integer cover(Integer source) {
        return 5;
    }
}
